var mysql = require('mysql')


var pool = mysql.createPool({
    host:'10.100.2.12',
    user:'root',
    password:'Wo4heike',
    database:'yingxinxin-qa',
    port:3306
})

var query = function (sql,sqlparam,callback) {
    pool.getConnection(function (err,conn) {
        if (err){
            callback(err,null,null)
        } else {
            conn.query(sql,function (qerr,vals,fields) {
                conn.release();
                callback(qerr,vals,fields)
            })
        }
    })
}


/*var query = function (sql,callback) {
    pool.getConnection(function (err,conn) {
        if (err){
            callback(err,null,null)
        } else {
            conn.query(sql,function (qerr,vals,fields) {
                conn.release();
                callback(qerr,vals,fields)
            })
        }
    })
}*/

/*query("select * from yxx_dictionary",function (err,vals,fields) {
    if (err) throw err;
    console.log("========"+vals[0].id)
})*/
module.exports=query;

//export  {query}
/*
var connection = mysql.createConnection({
    host:'10.100.2.12',
    user:'root',
    password:'Wo4heike',
    database:'yingxinxin-qa',
    port:3306
})

connection.connect()

connection.query('select * from yxx_dictionary',function (error,results,fields) {
    if (error) throw  error;
    console.log("solution is",results)
})

connection.end()
*/
